package com.godpaper.as9.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.control.CairngormEventDispatcher;
	import com.godpaper.as9.bussiness.delegates.ClassDelegate;
	import com.godpaper.as9.events.GetClassListEvent;
	import com.godpaper.as9.events.TryDeleteClassEvent;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;

	public class TryDeleteClassCommand extends CommandBase implements ICommand, IResponder
	{
		private var delegate:ClassDelegate;
		private var tryDeleteClassEvent:TryDeleteClassEvent;
		public function TryDeleteClassCommand()
		{
			super();
			delegate = new ClassDelegate(this);
		}
		
		override public function execute(event:CairngormEvent):void
		{
			tryDeleteClassEvent = TryDeleteClassEvent(event);
			delegate.delete_(tryDeleteClassEvent.cno);
		}
		
		override public function result(data:Object):void
		{
			if(data.result.info=="success")
			{
				CairngormEventDispatcher.getInstance().dispatchEvent(new GetClassListEvent());
			}else
			{
				Alert.show("Delete class failure!","FAILURE");
			}
		}
		
	}
}